package pers.mine.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import pers.mine.jo.Log;

public interface LogMapper extends BaseMapper<Log> {
    @Insert("INSERT INTO `log`(`info`,`tag`) VALUES (#{log.info},#{log.tag})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertTest(@Param("log") Log log);

    @Insert({"<script>"
            , "INSERT INTO `log`("
            , "  `info`"
            , "    <if test='log.tag!=null'> "
            , "        ,`tag`"
            , "    </if>"
            , ") VALUES ("
            , "  #{log.info}"
            , "    <if test='log.tag!=null'> "
            , "        ,#{log.tag}"
            , "    </if>"
            , ")"
            , "</script> "
    })
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertTestDynamicSql(@Param("log") Log log);
}
